package com.wms.ymcc.controller;

import com.wms.ymcc.doc.CourseDoc;
import com.wms.ymcc.doc.dto.SearchDto;
import com.wms.ymcc.result.JSONResult;
import com.wms.ymcc.service.ESCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : 阿盛哟
 * @description :
 * @createDate : 2025/6/18 22:37
 */
@RestController
// @RequestMapping("/esCourse")
public class ESCourseController {

    @Autowired
    private ESCourseService esCourseService;

    @PostMapping("/esCourse/save")
    @PreAuthorize("hasAnyAuthority('esCourse:save')")
    public JSONResult save(@RequestBody CourseDoc courseDoc) {
        esCourseService.save(courseDoc);
        return JSONResult.success();
    }


    @PostMapping("/course/search")
    public JSONResult search(@RequestBody SearchDto searchDto) {
        return JSONResult.success(esCourseService.search(searchDto));
    }
}